<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet"  href="../../static/layui/css/layui.css">
  <script src="../../static/layui/layui.js"></script>
</head>
<body>
<!-- 菜单栏 -->
<link rel="stylesheet" href="../../static/css/index.css">
<ul>
  <div th:each="item:${menuList}" class="display:inline-de">
    <li><a th:href="@{${item.path}}" th:text="${item.name}"></a></li>
  </div>
  <a th:href="@{/login}" style="float:right;font-size: 16px;margin: 17px;color: white;">> 登出</a>
</ul>
<from lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../static/css/form.css">
    <link rel="stylesheet" href="../../static/css/index.css">
    <title>货运单详情</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>

    <style type="text/css">
      .box {
        width: 800px;
        margin: 50px auto;
        border: 1px solid #DCDFE6;
        border-radius: 20px;
        padding: 20px;
      }

      .box:hover {
        box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
      }

      .box-title {
        text-align: center;
      }

      .box-table {
        margin-top: 20px;
      }
      .box-nav{
        text-align: center;
      }
    </style>
  </head>
  <body>
  <div id="content-carrier" class="form-container" style="padding-bottom: 50px">
    <h2 class="form-title" style="font-family: 幼圆;font-weight: bold">货运单信息</h2>
    <div class="form">
      <img src="../../static/img/paper.png" style="width: 120px;height: 150px;position: relative;left: 10%">
      <form class="form-content" th:object="${carrier}">
        <div style="display:flex;flex-wrap:wrap;">
          <!-- 第一列属性 -->
          <div style="flex-basis:50%;">
            <div class="form-row">
              <label>编号</label>
              <span th:text="*{id}"/>
            </div>
            <div class="form-row">
              <label>创建人</label>
              <span th:text="*{creatorName}"/>
            </div>
            <div class="form-row">
              <label>创建时间</label>
              <span th:text="*{time}"/>
            </div>
            <div class="form-row">
              <label>状态</label>
              <span th:text="*{state}"/>
            </div>
            <div class="form-row">
              <label>物流价</label>
              <span th:text="*{logisticsCost}"/>
            </div>
            <div class="form-row">
              <label>意外成本</label>
              <span th:text="*{unexpectedCost}"/>
            </div>
            <div class="form-row">
              <label>重量</label>
              <span th:text="*{weight}"/>
            </div>
          </div>
          <!-- 第二列属性 -->
          <div style="flex-basis:50%;">
            <div class="form-row">
              <label>起始点</label>
              <span th:text="*{start}"/>
            </div>
            <div class="form-row">
              <label>目的地</label>
              <span th:text="*{target}"/>
            </div>
            <div class="form-row">
              <label>收货人</label>
              <span th:text="*{consignee}"/>
            </div>
            <div class="form-row">
              <label>描述</label>
              <span th:text="*{desc}"/>
            </div>
            <div class="form-row">
              <label>总价</label>
              <span th:text="*{totalPrice}"/>
            </div>
            <div class="form-row">
              <label>货物</label>
              <span th:text="*{goods}"/>
            </div>
            <div class="form-row">
              <label>备注</label>
              <span th:text="*{remark}"/>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
  <div class="box">
    <div class="form-group">
      <h2 class="t2">关联派车单</h2>
      <table class="table table-bordered box-table">
        <tr>
          <th>编号</th>
          <th>创建时间</th>
          <th>关联货运单id</th>
          <th>货物内容</th>
          <th>司机名</th>
          <th>状态</th>
          <th>意外成本</th>
          <th>操作</th>
        </tr>
        <tr th:each="driverTruckOrders : ${driverTruckOrders}">
          <td th:text="${driverTruckOrders.id}"></td>
          <td th:text="${driverTruckOrders.careateTime}"></td>
          <td th:text="${driverTruckOrders.orderId}"></td>
          <td th:text="${driverTruckOrders.goods}"></td>
          <td th:text="${driverTruckOrders.realName}"></td>
          <td th:text="${driverTruckOrders.state}"></td>
          <td th:text="${driverTruckOrders.unexpectedCost}"></td>
          <td>
            <div class="layui-btn-container">
              <button class="layui-btn" test-active="Detail">详情</button>
            </div>
          </td>
        </tr>
      </table>
    </div>


    <script src="layer.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
  </div>
  </form>
  </div>
  </body>
</from>
<script>
  layui.use(function(){
    var layer = layui.layer
            ,form = layui.form
            ,laypage = layui.laypage
            ,element = layui.element
            ,laydate = layui.laydate
            ,util = layui.util;

    //触发事件
    util.on('test-active', {
      'Detail': function(){
        layer.open({
          type: 1
          ,resize: false
          ,shadeClose: true
          ,area: '800px'
          ,title: '操作记录'
          ,content: ['<table class="layui-table">'
            ,'<thead>'
            ,'<tr>'
            ,'<th>操作人id</th>'
            ,'<th>状态</th>'
            ,'<th>操作时间</th>'
            ,'<th>意外信息</th>'
            ,'<th>意外价格</th>'
            ,'</tr>'
            ,'</thead>'
            ,'<tbody>'
            ,'<tr th:each="operationRecord : ${operationRecord}">'
            ,'<td th:text="${operationRecord.operatorId}"></td>'
            ,'<td th:text="${operationRecord.type}"></td>'
            ,'<td th:text="${operationRecord.operateTime}"></td>'
            ,'<td th:text="${operationRecord.unexpectedInfo}"></td>'
            ,'<td th:text="${operationRecord.unexpectedPrice}"></td>'
            ,'</tr>'
            ,'</tbody>'
            ,'</table>'].join('')
          ,success: function(layero, index){
            layero.find('.layui-layer-content').css('overflow', 'visible');

            form.render().on('submit(saveLocation)', function(data){
              $.ajax({
                type: "post",
                url: "/driver/saveLocation",
                data: data.field,
                success:function (result) {
                  console.log(data)
                  window.parent.location.reload();
                  layer.closeAll();

                }
              });
              return false;
            });
          }
        });
      }
    });

  });
</script>
</body>
</html>
